home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Multimedia / PlayerPRO 4.5.5 Dev.Kit / Plug-Ins / Sound Filters Plugs / Backwards.c < prev    next >
C/C++ Source or Header  |  1995-10-08  |  2KB  |  77 lines

  1. /*    Backwards        */
  2. /*    v 0.2            */
  3. /*    1995 by Liane    */
  4.  
  5. //    Usage:
  6. //    Invert the selected part or all the waveform if
  7. //    there is no selection.
  8.  
  9. #include "MAD.h"
  10. #include "PPPlug.h"
  11.  
  12. #if defined(powerc) || defined(__powerc)
  13. enum {
  14.         PlayerPROPlug = kCStackBased
  15.         | RESULT_SIZE(SIZE_CODE( sizeof(OSErr)))
  16.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof( sData*)))
  17.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof( long)))
  18.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof( long)))
  19.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof( PPInfoPlug*)))
  20. };
  21.  
  22. ProcInfoType __procinfo = PlayerPROPlug;
  23. #else
  24. #include <A4Stuff.h>
  25. #endif
  26.  
  27.  
  28. OSErr main(     sData                    *theData,
  29.                 long                    SelectionStart,
  30.                 long                    SelectionEnd,
  31.                 PPInfoPlug                *thePPInfoPlug)
  32. {
  33.     long    i;
  34.     unsigned short    temp1, temp2;
  35.  
  36.     if (SelectionStart == SelectionEnd) {
  37.         SelectionStart = 0;
  38.         SelectionEnd = theData->size;
  39.     }
  40.  
  41.     switch( theData->amp)
  42.     {
  43.         case 8:
  44.         {
  45.             Ptr    orgPtr = theData->data, destPtr = orgPtr;
  46.  
  47.             orgPtr += SelectionStart;
  48.             destPtr += SelectionEnd - 1;
  49.             
  50.             for( i = 0; i < (SelectionEnd - SelectionStart) / 2; i++)    //just swap values
  51.             {
  52.                 temp1 = *orgPtr;
  53.                 temp2 = *destPtr;
  54.                 *orgPtr++ = temp2;
  55.                 *destPtr-- = temp1;
  56.             }
  57.         } break;
  58.         
  59.         case 16:
  60.         {
  61.             unsigned short    *orgPtr = (unsigned short*) theData->data, *destPtr = orgPtr;
  62.  
  63.             orgPtr += SelectionStart / 2;
  64.             destPtr += (SelectionEnd - 1) / 2;
  65.             
  66.             for( i = 0; i < (SelectionEnd - SelectionStart) / 4; i++)
  67.             {
  68.                 temp1 = *orgPtr;
  69.                 temp2 = *destPtr;
  70.                 *orgPtr++ = temp2;
  71.                 *destPtr-- = temp1;
  72.             }
  73.         } break;
  74.     }
  75.  
  76.     return noErr;
  77. }